﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="detailandmed_pandipidaja", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(DetailandmedPandipidaja))]
    public class DetailandmedPandipidajaSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IDetailandmedPandipidaja clazz;
        
        public DetailandmedPandipidajaSerializer(IDetailandmedPandipidaja clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.PandipidajaIsikuLiik!=null) {
                Writer.WriteStartElement("pandipidaja_isiku_liik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PandipidajaIsikuLiik))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.PandipidajaIsikukoodRegistrikood!=null) {
                Writer.WriteStartElement("pandipidaja_isikukood_registrikood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PandipidajaIsikukoodRegistrikood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.PandipidajaValisKood!=null) {
                Writer.WriteStartElement("pandipidaja_valis_kood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PandipidajaValisKood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.PandipidajaSynniaeg!=null) {
                Writer.WriteStartElement("pandipidaja_synniaeg");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.PandipidajaSynniaeg))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.PandipidajaNimi!=null) {
                Writer.WriteStartElement("pandipidaja_nimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PandipidajaNimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.PandipidajaEesnimi!=null) {
                Writer.WriteStartElement("pandipidaja_eesnimi");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PandipidajaEesnimi))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AadressRiik!=null) {
                Writer.WriteStartElement("aadress_riik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AadressRiik))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AadressRiikTekstina!=null) {
                Writer.WriteStartElement("aadress_riik_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AadressRiikTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AadressEhak!=null) {
                Writer.WriteStartElement("aadress_ehak");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AadressEhak))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AadressEhakTekstina!=null) {
                Writer.WriteStartElement("aadress_ehak_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AadressEhakTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Omandiliik!=null) {
                Writer.WriteStartElement("omandiliik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Omandiliik))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.OmandiliikTekstina!=null) {
                Writer.WriteStartElement("omandiliik_tekstina");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.OmandiliikTekstina))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MurdosaLugeja!=null) {
                Writer.WriteStartElement("murdosa_lugeja");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.MurdosaLugeja))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MurdosaNimetaja!=null) {
                Writer.WriteStartElement("murdosa_nimetaja");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.MurdosaNimetaja))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AlgusKpv!=null) {
                Writer.WriteStartElement("algus_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.AlgusKpv))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.LoppKpv!=null) {
                Writer.WriteStartElement("lopp_kpv");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.LoppKpv))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="pandipidaja_isiku_liik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_pandipidaja>pandipidaja_isiku_liik");
                }
                clazz.PandipidajaIsikuLiik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pandipidaja_isiku_liik")).Value;
            }
            if (Reader.LocalName=="pandipidaja_isikukood_registrikood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_pandipidaja>pandipidaja_isikukood_registrikood");
                }
                clazz.PandipidajaIsikukoodRegistrikood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pandipidaja_isikukood_registrikood")).Value;
            }
            if (Reader.LocalName=="pandipidaja_valis_kood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_pandipidaja>pandipidaja_valis_kood");
                }
                clazz.PandipidajaValisKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pandipidaja_valis_kood")).Value;
            }
            if (Reader.LocalName=="pandipidaja_synniaeg") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_pandipidaja>pandipidaja_synniaeg");
                }
                clazz.PandipidajaSynniaeg = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("pandipidaja_synniaeg")).Value;
            }
            if (Reader.LocalName=="pandipidaja_nimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_pandipidaja>pandipidaja_nimi");
                }
                clazz.PandipidajaNimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pandipidaja_nimi")).Value;
            }
            if (Reader.LocalName=="pandipidaja_eesnimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_pandipidaja>pandipidaja_eesnimi");
                }
                clazz.PandipidajaEesnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pandipidaja_eesnimi")).Value;
            }
            if (Reader.LocalName=="aadress_riik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_pandipidaja>aadress_riik");
                }
                clazz.AadressRiik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress_riik")).Value;
            }
            if (Reader.LocalName=="aadress_riik_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_pandipidaja>aadress_riik_tekstina");
                }
                clazz.AadressRiikTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress_riik_tekstina")).Value;
            }
            if (Reader.LocalName=="aadress_ehak") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_pandipidaja>aadress_ehak");
                }
                clazz.AadressEhak = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress_ehak")).Value;
            }
            if (Reader.LocalName=="aadress_ehak_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_pandipidaja>aadress_ehak_tekstina");
                }
                clazz.AadressEhakTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("aadress_ehak_tekstina")).Value;
            }
            if (Reader.LocalName=="omandiliik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_pandipidaja>omandiliik");
                }
                clazz.Omandiliik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("omandiliik")).Value;
            }
            if (Reader.LocalName=="omandiliik_tekstina") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_pandipidaja>omandiliik_tekstina");
                }
                clazz.OmandiliikTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("omandiliik_tekstina")).Value;
            }
            if (Reader.LocalName=="murdosa_lugeja") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_pandipidaja>murdosa_lugeja");
                }
                clazz.MurdosaLugeja = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("murdosa_lugeja")).Value;
            }
            if (Reader.LocalName=="murdosa_nimetaja") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_pandipidaja>murdosa_nimetaja");
                }
                clazz.MurdosaNimetaja = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("murdosa_nimetaja")).Value;
            }
            if (Reader.LocalName=="algus_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_pandipidaja>algus_kpv");
                }
                clazz.AlgusKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("algus_kpv")).Value;
            }
            if (Reader.LocalName=="lopp_kpv") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>detailandmed_pandipidaja>lopp_kpv");
                }
                clazz.LoppKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("lopp_kpv")).Value;
            }
        }
    }
}
